package com.ruoyi.system.controller;

import java.util.List;
import java.io.IOException;
import jakarta.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.log.annotation.Log;
import com.ruoyi.common.log.enums.BusinessType;
import com.ruoyi.common.security.annotation.RequiresPermissions;
import com.ruoyi.system.domain.SysReceiptInfo;
import com.ruoyi.system.service.ISysReceiptInfoService;
import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.common.core.utils.poi.ExcelUtil;
import com.ruoyi.common.core.web.page.TableDataInfo;

/**
 * 收货地址信息Controller
 * 
 * @author ruoyi
 * @date 2025-10-27
 */
@RestController
@RequestMapping("/receipt")
public class SysReceiptInfoController extends BaseController
{
    @Autowired
    private ISysReceiptInfoService sysReceiptInfoService;

    /**
     * 查询收货地址信息列表
     */
    @RequiresPermissions("system:info:list")
    @GetMapping("/list")
    public TableDataInfo list(SysReceiptInfo sysReceiptInfo)
    {
        startPage();
        List<SysReceiptInfo> list = sysReceiptInfoService.selectSysReceiptInfoList(sysReceiptInfo);
        return getDataTable(list);
    }

    /**
     * 导出收货地址信息列表
     */
    @RequiresPermissions("system:info:export")
    @Log(title = "收货地址信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, SysReceiptInfo sysReceiptInfo)
    {
        List<SysReceiptInfo> list = sysReceiptInfoService.selectSysReceiptInfoList(sysReceiptInfo);
        ExcelUtil<SysReceiptInfo> util = new ExcelUtil<SysReceiptInfo>(SysReceiptInfo.class);
        util.exportExcel(response, list, "收货地址信息数据");
    }

    /**
     * 获取收货地址信息详细信息
     */
    @RequiresPermissions("system:info:query")
    @GetMapping(value = "/{receiptInfoId}")
    public AjaxResult getInfo(@PathVariable("receiptInfoId") Long receiptInfoId)
    {
        return success(sysReceiptInfoService.selectSysReceiptInfoByReceiptInfoId(receiptInfoId));
    }

    /**
     * 新增收货地址信息
     */
    @RequiresPermissions("system:info:add")
    @Log(title = "收货地址信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody SysReceiptInfo sysReceiptInfo)
    {
        return toAjax(sysReceiptInfoService.insertSysReceiptInfo(sysReceiptInfo));
    }

    /**
     * 修改收货地址信息
     */
    @RequiresPermissions("system:info:edit")
    @Log(title = "收货地址信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody SysReceiptInfo sysReceiptInfo)
    {
        return toAjax(sysReceiptInfoService.updateSysReceiptInfo(sysReceiptInfo));
    }

    /**
     * 删除收货地址信息
     */
    @RequiresPermissions("system:info:remove")
    @Log(title = "收货地址信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{receiptInfoIds}")
    public AjaxResult remove(@PathVariable Long[] receiptInfoIds)
    {
        return toAjax(sysReceiptInfoService.deleteSysReceiptInfoByReceiptInfoIds(receiptInfoIds));
    }
}
